home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_PICT / Source / CommentedPSCode / RCS / Ovals,v < prev    next >
Encoding:
Text File  |  1995-06-12  |  11.0 KB  |  539 lines

  1. head     1.8;
  2. branch   ;
  3. access   ;
  4. symbols  beta10:1.7;
  5. locks    death:1.8;
  6. comment  @# @;
  7.  
  8.  
  9. 1.8
  10. date     93.04.04.23.30.51;  author death;  state Exp;
  11. branches ;
  12. next     1.7;
  13.  
  14. 1.7
  15. date     93.01.09.21.07.32;  author death;  state Exp;
  16. branches ;
  17. next     1.6;
  18.  
  19. 1.6
  20. date     93.01.01.11.51.39;  author death;  state Exp;
  21. branches ;
  22. next     1.5;
  23.  
  24. 1.5
  25. date     92.12.31.15.35.06;  author death;  state Exp;
  26. branches ;
  27. next     1.4;
  28.  
  29. 1.4
  30. date     92.12.05.23.07.34;  author death;  state Exp;
  31. branches ;
  32. next     1.3;
  33.  
  34. 1.3
  35. date     92.12.03.18.02.07;  author death;  state Exp;
  36. branches ;
  37. next     1.2;
  38.  
  39. 1.2
  40. date     92.11.27.19.38.13;  author death;  state Exp;
  41. branches ;
  42. next     1.1;
  43.  
  44. 1.1
  45. date     92.11.08.09.29.00;  author death;  state Exp;
  46. branches ;
  47. next     ;
  48.  
  49.  
  50. desc
  51. @@
  52.  
  53.  
  54. 1.8
  55. log
  56. @Sun Apr  4 23:30:51 PDT 1993
  57. @
  58. text
  59. @%BEGIN Ovals
  60.  
  61. %%%%%%%%%%%%%
  62. %    Note:
  63. %    setupForArcPath, penWidth and penHeight defined in Common file
  64. %%%%%%%%%%%%%
  65.  
  66. %%%%%%%%%%%%%
  67. %    Name:    ovalpath
  68. %    Syntax:    top left bottom right ovalpath -
  69. %    About:    Given the coordinates for a rectangle, builds an oval.
  70. %            Note: this uses and sets the last* global values.
  71. %%%%%%%%%%%%%
  72. /ovalpath
  73. {
  74.     /lastright exch def
  75.     /lastbottom exch def
  76.     /lastleft exch def
  77.     /lasttop exch def
  78.  
  79.     newpath
  80.         lastright lastleft sub    % compute width & height
  81.         lastbottom lasttop sub
  82.         lastbottom lastleft setupForArcPath
  83.         0 360 arc
  84.     closepath
  85. } def
  86.  
  87.  
  88. %%%%%%%%%%%%%
  89. %    Name:    frameOval        [0050]
  90. %    Syntax:    top left bottom right start-angle stop-angle frameArc -
  91. %    About:    Use coords of a rectangle, this frames (outlines) the shape of
  92. %        an oval from it, using the current penWidth and penHeight.
  93. %        If the penwidth and height are both 1, then we do a special case
  94. %        framing, because it looks a bit better, and will doubtlessly be
  95. %        used frequently.  Otherwise, we use the setupForArcPath routine to
  96. %        build the path of an oval, and then build the path of one inside it.
  97. %        The inner one is inset by the penWidth & Height values, and produces
  98. %        the effect of the oval drawn with a pen of that size.
  99. %        Note that the last* values are modified and used here
  100. %%%%%%%%%%%%%
  101. /frameOval
  102. {
  103.     /lastright exch def
  104.     /lastbottom exch def
  105.     /lastleft exch def
  106.     /lasttop exch def
  107.     
  108.     gsave
  109.         penPattern usePattern
  110.         
  111.         /thewidth lastright lastleft sub def
  112.         /theheight lastbottom lasttop sub def
  113.         %
  114.         %    special case for pens that are 1 by 1 pixel
  115.         %
  116.         penHeight 1 eq
  117.         penWidth 1 eq
  118.         and
  119.         {
  120.             newpath
  121.                 thewidth theheight lastbottom lastleft setupForArcPath
  122.                 0 360 arc
  123.             closepath
  124.             stroke
  125.         }
  126.         {
  127.             %
  128.             %    More general case for penwidths and heights != 1
  129.             %
  130.             penHeight 0 gt    % don't draw with a 0 sized pen.
  131.             penWidth 0 gt
  132.             and
  133.             {
  134.                 /startmatrix  matrix  currentmatrix def
  135.                 newpath
  136.                     thewidth theheight lastbottom lastleft setupForArcPath
  137.                     0 360 arc
  138.                 closepath
  139.                     %
  140.                     %    Recover from distortions setupForArcPath did. 
  141.                     %    Calculate inner oval of the framed shape.
  142.                     %
  143.                     startmatrix setmatrix
  144.  
  145.                     /innerRight lastright penWidth sub 1 add def
  146.                     /innerTop  lasttop penHeight add 1 sub def
  147.                     /innerLeft lastleft penWidth add 1 sub def
  148.                     /innerBottom lastbottom penHeight sub 1 add def
  149.                     /innerWidth innerRight innerLeft sub def
  150.                     /innerHeight innerBottom innerTop sub def
  151.                     
  152.                     innerWidth innerHeight innerBottom innerLeft
  153.                     setupForArcPath
  154.                     360 0  arcn
  155.                 closepath
  156.                 fill
  157.             }
  158.             if
  159.         }
  160.         ifelse
  161.     grestore
  162. } def
  163.  
  164. %%%%%%%%%%%%%
  165. %    Name:    paintOval        [0051]
  166. %    Syntax:    t l b r paintOval -
  167. %    About:    pass parameters to ovalpath, and fill the resulting oval.
  168. %%%%%%%%%%%%%
  169. /paintOval
  170. {
  171.     gsave
  172.         penPattern usePattern
  173.         ovalpath
  174.         fill
  175.     grestore
  176. }
  177. def
  178.  
  179. %%%%%%%%%%%%%
  180. %    Name:    eraseOval        [0052]
  181. %    Syntax:    t l b r eraseOval -
  182. %    About:    pass parameters to ovalpath, and erase the resulting oval.
  183. %%%%%%%%%%%%%
  184. /eraseOval
  185. {
  186.     gsave
  187.         backPattern usePattern
  188.         ovalpath
  189.         fill
  190.     grestore
  191. }
  192. def
  193.  
  194. %%%%%%%%%%%%%
  195. %    Name:    invertOval        [0053]
  196. %    Syntax:    t l b r invertOval -
  197. %    About:    We can't duplicate the invert effect, so we just call ovalpath
  198. %            to consume the parameters and set last* values.
  199. %%%%%%%%%%%%%
  200. /invertOval
  201. {
  202.     gsave
  203.         ovalpath
  204.     grestore
  205. }
  206. def
  207.  
  208. %%%%%%%%%%%%%
  209. %    Name:    fillOval        [0054]
  210. %    Syntax:    t l b r fillOval -
  211. %    About:    Use the arguments to build an oval path which we then fill
  212. %%%%%%%%%%%%%
  213. /fillOval
  214. {
  215.     gsave
  216.         fillPattern usePattern
  217.         ovalpath
  218.         fill
  219.     grestore
  220. }
  221. def
  222.  
  223. %%%%%%%%%%%%%
  224. %    Name:    frameSameOval        [0058]
  225. %    Syntax:    - frameSameOval -
  226. %    About:    Using the last* values, frame an oval
  227. %%%%%%%%%%%%%
  228. /frameSameOval
  229.     { lasttop lastleft lastbottom lastright frameOval }
  230. def
  231.  
  232. %%%%%%%%%%%%%
  233. %    Name:    paintSameOval        [0059]
  234. %    Syntax:    - paintSameOval -
  235. %    About:    Using the last* values, paint an oval
  236. %%%%%%%%%%%%%
  237. /paintSameOval
  238.     { lasttop lastleft lastbottom lastright paintOval }
  239. def
  240.  
  241. %%%%%%%%%%%%%
  242. %    Name:    eraseSameOval        [005A]
  243. %    Syntax:    - eraseSameOval -
  244. %    About:    Using the last* values, erase an oval
  245. %%%%%%%%%%%%%
  246. /eraseSameOval
  247.     { lasttop lastleft lastbottom lastright eraseOval }
  248. def
  249.  
  250. %%%%%%%%%%%%%
  251. %    Name:    invertSameOval        [005B]
  252. %    Syntax:    - invertSameOval -
  253. %    About:    Using the last* values, invert an oval
  254. %%%%%%%%%%%%%
  255. /invertSameOval
  256.     { lasttop lastleft lastbottom lastright invertOval }
  257. def
  258.  
  259. %%%%%%%%%%%%%
  260. %    Name:    fillSameOval        [005C]
  261. %    Syntax:    - fillSameOval -
  262. %    About:    Using the last* values, fill an oval
  263. %%%%%%%%%%%%%
  264. /fillSameOval
  265.     { lasttop lastleft lastbottom lastright fillOval }
  266. def
  267.  
  268. %END Ovals
  269. @
  270.  
  271.  
  272. 1.7
  273. log
  274. @Sat Jan  9 21:07:32 PST 1993
  275. @
  276. text
  277. @d87 4
  278. a90 4
  279.                     /innerRight lastright penWidth sub def
  280.                     /innerTop  lasttop penHeight add def
  281.                     /innerLeft lastleft penWidth add def
  282.                     /innerBottom lastbottom penHeight sub def
  283. @
  284.  
  285.  
  286. 1.6
  287. log
  288. @Fri Jan  1 11:51:39 PST 1993
  289. @
  290. text
  291. @@
  292.  
  293.  
  294. 1.5
  295. log
  296. @Thu Dec 31 15:35:06 PST 1992
  297. @
  298. text
  299. @@
  300.  
  301.  
  302. 1.4
  303. log
  304. @Sat Dec  5 23:07:33 PST 1992
  305. @
  306. text
  307. @d3 4
  308. a6 3
  309. %
  310. %    setupForArcPath, penWidth, penHeight are defined in the common file
  311. %
  312. d8 6
  313. a13 10
  314. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  315. %    utility:    ovalpath
  316. %    Syntax:    t l b r ovalpath -
  317. %    Description:
  318. %        takes a rectangle (top left bottom right) and builds an oval from it,
  319. %        setting the last rect values in the process  This now relies on
  320. %        setupForArcPath to get the job done.  This renders this routine
  321. %        almost useless.  The relevant oval routines could do this on thier
  322. %        own easily.  But, I figure better to have it all centralized here.
  323. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  324. a19 3
  325.     
  326.     /thewidth lastright lastleft sub def
  327.     /theheight lastbottom lasttop sub def
  328. d22 3
  329. a24 1
  330.         thewidth theheight lastbottom lastleft setupForArcPath
  331. d30 13
  332. a42 20
  333.  
  334. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  335. %    Opcode:    0050
  336. %    Name:    frameOval
  337. %    Syntax:    t l b r frameOval -
  338. %    Description:
  339. %        Takes a rectangle (top left bottom right) and builds the frame (outline) of
  340. %        an oval from it, using the current penwidth and height
  341. %        This is, unfortunately, a very long routine.  It's made up of
  342. %        basically 3 parts:  A case when the penwidth and height are both 1,
  343. %        a case when the oval width is greater than the oval height, and a case when the
  344. %        oval height is greater than the oval width.  The first is provided basically as a
  345. %        special case, since this will probably be the most common case for thi to be called,
  346. %        and this case doesn't look as good if processed by the others.  In the other two
  347. %        cases, we necessarily distort user space so we can draw an oval.  Note that this
  348. %        also involves drawing an oval within the ovalso that we can produce the
  349. %        illusion of an ovalframed by different penwidths and heights.
  350. %    Weirdnesses:
  351. %        We use the lastrect globals for local variable use here...
  352. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  353. d72 1
  354. a72 1
  355.             penHeight 0 gt    % assure that we aren't trying to draw with a 0 sized pen.
  356. a79 1
  357.                 startmatrix setmatrix
  358. d81 6
  359. d94 2
  360. a95 1
  361.                     innerWidth innerHeight innerBottom innerLeft setupForArcPath
  362. d106 2
  363. a107 4
  364.  
  365. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  366. %    Opcode:    0051
  367. %    Name:    paintOval
  368. d109 2
  369. a110 3
  370. %    Description:
  371. %        takes a rectangle  and paints its oval on the screen
  372. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  373. d121 2
  374. a122 4
  375.  
  376. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  377. %    Opcode:    0052
  378. %    Name:    eraseOval
  379. d124 2
  380. a125 3
  381. %    Description:
  382. %        takes a rectangle  and paints its oval on the screen using the background pattern
  383. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  384. d136 2
  385. a137 4
  386.  
  387. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  388. %    Opcode:    0053
  389. %    Name:    invertOval
  390. d139 3
  391. a141 4
  392. %    Description:
  393. %        As far as I can tell, no one usese this for anything.  Build the path in order to
  394. %        get the side effect of string the 'last Rectangleangle' in case we need it.
  395. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  396. d150 2
  397. a151 4
  398.  
  399. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  400. %    Opcode:    0054
  401. %    Name:    fillOval
  402. d153 2
  403. a154 4
  404. %    Description:
  405. %        takes a Rectangle, and passes it to ovalpath which builds a path. 
  406. %        Fill the resulting path with the fill pattern
  407. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  408. d165 2
  409. a166 4
  410.  
  411. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  412. %    Opcode:    0058
  413. %    Name:    frameSameOval
  414. d168 2
  415. a169 3
  416. %    Description:
  417. %        Use the last... values to call frameOval and thus frame the last rectangular area used.
  418. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  419. d174 2
  420. a175 4
  421.  
  422. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  423. %    Opcode:    0059
  424. %    Name:    paintSameOval
  425. d177 2
  426. a178 3
  427. %    Description:
  428. %        Use the last... values to call paintOval and thus paint the last rectangular area used.
  429. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  430. d183 2
  431. a184 4
  432.  
  433. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  434. %    Opcode:    005A
  435. %    Name:    eraseSameOval
  436. d186 2
  437. a187 3
  438. %    Description:
  439. %        Use the last... values to call eraseOval and thus erase the last rectangular area used.
  440. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  441. d192 2
  442. a193 4
  443.  
  444. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  445. %    Opcode:    005B
  446. %    Name:    invertSameOval
  447. d195 2
  448. a196 3
  449. %    Description:
  450. %        Use the last... values to call invertOval and thus invert the last rectangular area used.
  451. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  452. d201 2
  453. a202 4
  454.  
  455. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  456. %    Opcode:    005C
  457. %    Name:    fillSameOval
  458. d204 2
  459. a205 3
  460. %    Description:
  461. %        Use the last... values to call fillOval and thus fill the last rectangular area used.
  462. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  463. a208 1
  464.  
  465. @
  466.  
  467.  
  468. 1.3
  469. log
  470. @Thu Dec  3 18:02:07 PST 1992
  471. @
  472. text
  473. @d62 4
  474. a65 18
  475.     penPattern usePattern
  476.     
  477.     /thewidth lastright lastleft sub def
  478.     /theheight lastbottom lasttop sub def
  479.     %
  480.     %    special case for pens that are 1 by 1 pixel
  481.     %
  482.     penHeight 1 eq
  483.     penWidth 1 eq
  484.     and
  485.     {
  486.         newpath
  487.             thewidth theheight lastbottom lastleft setupForArcPath
  488.             0 360 arc
  489.         closepath
  490.         stroke
  491.     }
  492.     {
  493. d67 1
  494. a67 1
  495.         %    More general case for penwidths and heights != 1
  496. d69 2
  497. a70 2
  498.         penHeight 0 gt    % assure that we aren't trying to draw with a 0 sized pen.
  499.         penWidth 0 gt
  500. a72 1
  501.             /startmatrix  matrix  currentmatrix def
  502. a75 1
  503.             startmatrix setmatrix
  504. d77 1
  505. a77 11
  506.                 /innerRight lastright penWidth sub def
  507.                 /innerTop  lasttop penHeight add def
  508.                 /innerLeft lastleft penWidth add def
  509.                 /innerBottom lastbottom penHeight sub def
  510.                 /innerWidth innerRight innerLeft sub def
  511.                 /innerHeight innerBottom innerTop sub def
  512.                 
  513.                 innerWidth innerHeight innerBottom innerLeft setupForArcPath
  514.                 360 0  arcn
  515.             closepath
  516.             fill
  517. d79 29
  518. a107 3
  519.         if
  520.     }
  521.     ifelse
  522. @
  523.  
  524.  
  525. 1.2
  526. log
  527. @Fri Nov 27 19:38:13 PST 1992
  528. @
  529. text
  530. @@
  531.  
  532.  
  533. 1.1
  534. log
  535. @Sun Nov  8 09:29:00 PST 1992
  536. @
  537. text
  538. @@
  539.